package com.yidu.t299.service.chr.impl;

import com.yidu.t299.dao.chr.GradessMapper;
import com.yidu.t299.domain.chr.Grade;
import com.yidu.t299.service.chr.GradessBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class GradessBizImpl implements GradessBiz {
    @Autowired
    private GradessMapper gradessMapper;

    @Override
    public List<Grade> selectByPage(int rows, int page, String condition) {
        return gradessMapper.selectByPage(rows,page,condition);
    }

    @Override
    public String getCondition(String studentName, String className, String schoolName, String lessonName) {
        String condition = " ";
        //自定义过滤条件(学员名称和校区名称)
        if (studentName != null && studentName.trim().length() != 0) {
            condition += " and sm.student_name like '%" + studentName+"%'";
        }
        if (className != null && className.trim().length() != 0) {
            condition += " and c.class_name like '%" + className+"%'";
        }
        if (schoolName != null && schoolName.trim().length() != 0){
            condition += " and s.school_name like '%" + schoolName +"%'";
        }
        if (lessonName != null && lessonName.trim().length() != 0){
            condition += " and l.lesson_name like '%" + lessonName +"%'";
        }
        // 返回条件字符串
        return condition;
    }
}
